package top.cardone.api.v1.configuration.i18nInfo

import org.apache.commons.lang3.StringUtils
import top.cardone.configuration.service.I18nInfoService
import top.cardone.context.ApplicationContextHolder
import top.cardone.core.CodeException

class u0001 implements java.io.Serializable {
    def input(input) {
        def newInput = [:]


        newInput
    }

    def validation(input) {
//      if (StringUtils.isBlank(input?.i18nInfoId)) {
//          throw new CodeException("i18nInfoId required", "I18nInfo标识必填")
//      }
//
//      if (StringUtils.isBlank(input?.name)) {
//          throw new CodeException("name required", "I18nInfo名称必填")
//      }
//
//      if (StringUtils.length(input?.name) < 4) {
//          throw new CodeException("name minlength", "I18nInfo名称需{0}个字符以上", 4)
//      }
//
//      if (StringUtils.length(input?.name) > 255) {
//          throw new CodeException("name maxlength", "I18nInfo名称需小于{0}个字符", 255)
//      }

		def readOne = ["i18nInfoCode": input.i18nInfoCode, "object_id": "i18nInfoId"]

		String dbI18nInfoId = ApplicationContextHolder.getBean(I18nInfoService.class).readOne(String.class, readOne)

		if ((dbI18nInfoId != null) && !StringUtils.equals(dbI18nInfoId, input.i18nInfoId)) {
			throw new CodeException("i18nInfoId already exists", "I18nInfo编号已经存在")
		}
    }

    def func(input) {
		ApplicationContextHolder.getBean(I18nInfoService.class).updateCache(input)
    }

    def output(output) {
		['updateCount': output]
    }
}